from django.shortcuts import render

from utils.common_cache import add_cache
from utils.common_mixin import CommonListModelMixin as ListModelMixin
from rest_framework.viewsets import GenericViewSet

from banner.models import Banner
from banner.serializerls import BannerSerializer

class BannerView(ListModelMixin, GenericViewSet):
    queryset = Banner.objects.filter(is_show=True,is_delete=False).order_by('order')[:4]
    serializer_class = BannerSerializer  # 序列化类

    @add_cache
    def list(self, request, *args, **kwargs):
        res = super().list(request, *args, **kwargs)
        return res


